﻿/*using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SapNwRfc;
using System.Linq;

namespace VOL.WebApi.Controllers.SAP
{
    [Route("api/saptest")]
    [ApiController]
    public class sap_test : ControllerBase
    {
        /// <summary>
        /// 此方法调用SAP ECC6.0 RFC成功的例子
        /// 条件如下：
        /// 1、dotnet需要安装的nuget SapNwRfc 1.4.0;
        /// 2、dotnet平台net5.0环境支持；
        /// 3、复制nwrfc750P_6-70002755\\nwrfcsdk\lib下的dll文件到windows\system32目录下；
        /// 4、本程序的运维VS2022 
        /// </summary>
        /// <returns></returns>
        [HttpGet, Route("conn_sap")]
        public dynamic Conn_sap()
        {
            *//*string connectionString = "AppServerHost=10.100.8.126; SystemNumber=00; User=c000541; Password=5Tgb6yhn; Client=700; Language=ZH; PoolSize=5; Trace=8";//测试系统
                                                                                                                                                                   // string connectionString = "AppServerHost=10.100.8.124; SystemNumber=00; User=c000541; Password=1qaz2wsx; Client=700; Language=ZH; PoolSize=5; Trace=8";//正式系统
            using var connection = new SapConnection(connectionString);
            connection.Connect();
            using var someFunction = connection.CreateFunction("Z_GET_MATERIAL_RFC");
            var result = someFunction.Invoke<SomeFunctionResult>(new SomeFunctionParameters
            {
                I_WERKS = "9000",
            });*/

            /*var removedb = new MyDbContext();
            string[] MATNRS = result.ET_MATL.Select(e => e.MATNR).ToArray();
            IQueryable<sap_mara> _query = removedb.sap_mara.Where(t => MATNRS.Contains(t.matnr));
            removedb.RemoveRange(_query);
            removedb.SaveChanges();

            using (var db = new MyDbContext())
            {

                SomeFunctionitem[] items = result.ET_MATL;
                for (int i = 0; i < items.Length; i++)
                {
                    sap_mara sap_mara = new sap_mara();
                    sap_mara.matnr = items[i].MATNR;
                    sap_mara.maktx = items[i].MAKTX;
                    //db.sap_mara.Remove(sap_mara);
                    db.sap_mara.Update(sap_mara);
                }
                // sap_mara sap_Mara = new sap_mara();

                db.SaveChanges();
            };*//*

            // return result.ET_MATL;
            return "";
        }
        /// <summary>
        /// 输入参数
        /// </summary>
        class SomeFunctionParameters
        {
           [SapName("I_WERKS")]
            public string I_WERKS { get; set; }
        }
        /// <summary>
        /// 输出参数
        /// </summary>
        class SomeFunctionResult
        {
          [SapName("ET_MATL")]
            public SomeFunctionitem[] ET_MATL { get; set; }
        }

        /// <summary>
        /// 对应的SAP中返回的结构
        /// </summary>
        class SomeFunctionitem
        {
            //[SapName("MATNR")]//可以不用
            public string MATNR { get; set; }
            //[SapName("WERKS")]
            public string WERKS { get; set; }
            // [SapName("MAKTX")]
            public string MAKTX { get; set; }

        }
    }
}
*/